package com.wenbai.servicelightluxurystickers.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.wenbai.servicelightluxurystickers.entity.StickForumMember;
import com.wenbai.servicelightluxurystickers.mapper.StickForumMemberMapper;
import com.wenbai.servicelightluxurystickers.service.StickForumMemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class StickForumMemberImpl implements StickForumMemberService {

    @Autowired
    private StickForumMemberMapper stickForumMemberMapper;

    @Override
    public List<StickForumMember> selectMember(String id) {
        return stickForumMemberMapper.selectByMemberId(id);
    }

    @Transactional
    public void updateManage(int userId,int forumId) {
        stickForumMemberMapper.updateRoleZero(forumId, userId);
        stickForumMemberMapper.updateRoleOne(forumId, userId);
        stickForumMemberMapper.updateUserManage(userId);
    }

    @Override
    public void insertManage(Long userId, Long forumId) {
        StickForumMember stickForumMember = new StickForumMember();
        stickForumMember.setForumId(forumId);
        stickForumMember.setUserId(userId);
        stickForumMember.setRole("0");
        stickForumMemberMapper.insert(stickForumMember);
    }

    @Override
    public List<StickForumMember> selectMemberByUserId(int userId) {
        return stickForumMemberMapper.selectForumMemberByUserId(userId);
    }
}
